﻿jQuery(document).ready(function($){
	
	// run on page load
	$(document).ready(function(){
		
		// responsive behavior
		$(window).resize(function(){
			screenRespond();
		});
		screenRespond();
		
		// tabs
		$('.wp-tabify-this-zone').wpTabs({ accordion: 768 });
		
		// slideshow
		$('.slide-item').slides({
			navigation: true,
			paging: true
		});
		
	});
	
	// responsive behavior
	function screenRespond(){
		
		// small screen
		if($(window).width() < 768){
			
			// small screen nav menu
			$('.top-nav').spNav();
			
		}
		
		// desktop
		else{
			
			// remove small screen nav menu
			$('.top-nav').spNav({ destroy: true });
			
		}
	}
	
});

/* jQuery.spNav v1.0, by Kyle Schaeffer // Protiviti */
(function(a){a.fn.spNav=function(b){var c={style:"drawer",accordion:false,overlay:false,label:"Menu",speed:250,destroy:false,animate:function(d){a(d).next(".ui-spnav").slideToggle(c.speed)},canvas:"#s4-workspace"};var b=a.extend(c,b);return this.each(function(e){var f=a(this);if(c.destroy){a(".ui-spnav, #ui-canvas-overlay, "+c.canvas).stop(true,true);a(".ui-spnav").css("right","");a(c.canvas).css("overflow","").css("left","");a("#ui-canvas-overlay").remove();a(f).removeClass("ui-spnav ui-style-overlay ui-off-canvas").show().siblings(".ui-menu-button").remove();a(f).find("li.dynamic-children > ul").show().siblings(".ui-expand-button").remove()}else{if(!a(this).hasClass("ui-spnav")){var d=a('<a class="ui-menu-button" href="#"><span class="ui-icon-menu"><span class="line1" /><span class="line2" /><span class="line3" /></span><span class="ui-menu-label">'+c.label+'</span><span class="ui-icon" /></a>');a(d).click(function(g){g.preventDefault();c.animate(a(this));a(this).children(".ui-icon").toggleClass("ui-icon-open")});a(f).addClass("ui-spnav").hide().before(d);if(c.overlay){a(f).addClass("ui-overlay")}if(c.accordion){a(f).find("li.dynamic-children > a").each(function(g){var j=a(this);a(j).siblings("ul").hide();var h=a('<a class="ui-expand-button" href="#"><span class="ui-icon" /></a>');a(h).click(function(i){i.preventDefault();a(this).siblings("ul").slideToggle(c.speed);a(this).children(".ui-icon").toggleClass("ui-icon-open")});a(j).before(h)})}if(c.style=="off-canvas"){a(f).addClass("ui-off-canvas").show();c.animate=function(h){a(".ui-spnav, #ui-canvas-overlay, "+c.canvas).stop(true,true);var g=a(c.canvas).css("left")=="auto"||parseInt(a(c.canvas).css("left"))==0?true:false;a(h).next(".ui-spnav").animate({right:g?"15%":"100%"},c.speed);a(c.canvas).css("overflow",g?"hidden":"auto").animate({left:g?"85%":"0%"},c.speed);if(g){a(c.canvas).append('<div id="ui-canvas-overlay" style="display:none;"></div>');a("#ui-canvas-overlay").fadeIn(c.speed);a("#ui-canvas-overlay").click(function(){a(h).click()})}else{a("#ui-canvas-overlay").fadeOut(c.speed,function(){a(this).remove()})}}}}}})}})(jQuery);

/* jQuery.wpTabs v2.1, by Kyle Schaeffer // Protiviti */
(function(a){a.fn.wpTabs=function(b){var c={accordion:false};var b=a.extend(c,b);if(a("#MSOLayout_InDesignMode").val()==0){return this.each(function(e){var d=a(this).closest(".ms-webpart-zone");a(d).addClass("wptabs");var f=a('<ul class="wptabs-nav" />');a(this).closest(".ms-webpart-zone").children(".ms-webpartzone-cell").each(function(){if(!a(this).children().eq(0).hasClass("ms-hide")){a(f).append('<li><a href="#'+a(this).attr("id")+'">'+a(this).find(".ms-webpart-titleText").text()+"</a></li>")}});a(d).prepend(f);a(d).find(".ms-webpart-cell-vertical").css("display","block");if(window.jQuery.ui){a(d).tabs()}if(c.accordion){var g=function(){if(a(window).width()<=c.accordion){if(!a(d).hasClass("wptabs-accordion")){a(d).addClass("wptabs-accordion");a(d).children(".wptabs-nav").hide();a(d).find(".wptabs-nav li a").each(function(){var h=a(this);var i=a('<h3 class="wptabs-accordion-header"><a href="'+a(h).attr("href")+'">'+a(h).text()+'<span class="ui-icon"></span></a></h3>');if(a(h).parent("li").hasClass("ui-state-active")){a(i).addClass("ui-state-active")}a(i).children("a").click(function(k){k.preventDefault();var j=a(this);a(d).find(".wptabs-accordion-header").removeClass("ui-state-active");a(i).addClass("ui-state-active");a(".ui-tabs-panel").stop(true,true);a(".ui-tabs-panel:visible:not("+a(j).attr("href")+")").slideUp(250);a(a(j).attr("href")).slideDown(250,function(){a(h).click()})});a(a(h).attr("href")).before(i)})}}else{a(d).children(".wptabs-nav").show();a(d).find(".wptabs-accordion-header").remove();a(d).removeClass("wptabs-accordion")}};a(window).resize(function(){g()});g()}})}}})(jQuery);

/* jQuery.slides v1.2, by Kyle Schaeffer // Protiviti */
(function(a){a.fn.slides=function(c){var e=false;var f={effect:"pan",delay:8000,speed:250,navigation:false,paging:false};var c=a.extend(f,c);var b=function(k,m,i,j){d(k);a(k).find(".ui-slideshow-nav li").removeClass("ui-active");a(k).find(".ui-slideshow-nav li:eq("+a(i).prevAll("li").size()+")").addClass("ui-active");var g=a(m).width();var l=a(m).height();var n="-=";var o=g;if(j=="left"){n="+=";o=g*-1}a(k).css("width",g+"px").css("height",l+"px");if(f.effect=="fade"){a(m).css("z-index","1").animate({opacity:"0.75"},f.speed,function(){a(this).hide()});a(i).css("position","absolute").css("z-index","2").css("opacity","0").css("top","0px").css("left","0px").width(g).height(l).show().animate({opacity:"1"},f.speed,function(){a(this).css("position","static").css("width","auto").css("height","auto");a(k).css("width","auto").css("height","auto");var p=a(this);var h=a(p).next("li");if(a(h).size()==0){h=a(p).siblings("li").first()}e=setTimeout(function(){d(k);b(k,p,h,"right")},f.delay)})}else{a(m).css("position","absolute").css("left","0px").width(g).height(l).animate({left:n+g},f.speed,function(){a(this).hide().css("position","static").css("width","auto").css("height","auto")});a(i).css("position","absolute").css("left",o+"px").width(g).height(l).show().animate({left:n+g},f.speed,function(){a(this).css("position","static").css("width","auto").css("height","auto");a(k).css("width","auto").css("height","auto");var p=a(this);var h=a(p).next("li");if(a(h).size()==0){h=a(p).siblings("li").first()}e=setTimeout(function(){d(k);b(k,p,h,"right")},f.delay)})}};var d=function(g){clearTimeout(e);a(g).find("li").stop(true,true)};if(this.length>1&&(a("#MSOLayout_InDesignMode").val()==0||a("#MSOLayout_InDesignMode").val()=="")){return this.each(function(j){var h=a(this).parent().closest("div");if(!a(h).hasClass("ui-slideshow")){a(h).addClass("ui-slideshow");if(f.navigation){a(h).append('<ul class="ui-slideshow-nav" />')}if(f.paging){a(h).append('<ul class="ui-slideshow-paging"><li class="ui-slide-prev"><a href="#prev">Previous</a></li><li class="ui-slide-next"><a href="#next">Next</a></li></ul>');a(h).children(".ui-slideshow-paging").find(".ui-slide-prev a").click(function(m){m.preventDefault();d(h);var n=a(h).find("li:visible:eq(0)");var i=a(n).prev("li");if(a(i).size()==0){i=a(n).siblings("li").last()}b(h,n,i,"left")});a(h).children(".ui-slideshow-paging").find(".ui-slide-next a").click(function(m){m.preventDefault();d(h);var n=a(h).find("li:visible:eq(0)");var i=a(n).next("li");if(a(i).size()==0){i=a(n).siblings("li").first()}b(h,n,i,"right")})}var l=a(h).find("li:eq(0)");var k=a(h).find("li:eq(1)");e=setTimeout(function(){b(h,l,k,"right")},f.delay)}else{a(this).closest("li").hide()}if(f.navigation){var g=a('<li><a href="#'+(j+1)+'">'+(j+1)+"</a></li>");if(j==0){a(g).addClass("ui-active")}a(g).find("a").click(function(m){m.preventDefault();var n=a(h).find("li:visible:eq(0)");var i=a(h).find("li:eq("+a(this).parent().prevAll("li").size()+")");if(!a(i).is(":visible")){d(h);b(h,n,i,"right")}});a(h).children(".ui-slideshow-nav").append(g)}})}}})(jQuery);
